
<%@ page contentType="text/html;charset=utf-8" language="java" %>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%
    String path = request.getContextPath();
    String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN""http://www.w3.org/TR/html4/loose.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <base href="<%=basePath%>">
    <meta charset="UTF-8">
    <meta name="viewport" content="initial-scale=1, maximum-scale=1, user-scalable=no">
    <meta name="format-detection" content="telephone=no">
    <link rel="stylesheet" type="text/css" href="<c:url value='/resource/css/main.css'/>"/>
    <script type="text/javascript" src="<c:url value='/resource/js/jquery-1.11.1.min.js'/>"></script>
    <script type="text/javascript" src="<c:url value='/resource/js/num-alignment.js'/>"></script>
    <script type="text/javascript" src="<c:url value='/resource/js/jquery.cookie.js'/>"></script>
    <title>验收资料审核</title>
</head>
<body>
<div class="btn_box4">
    <a href="profile/index.html" class=" back">返回</a>
    <a href="profile/logout" class=" logout">注销</a>
</div>
<div id="tab_ul">
    <ul class="zczh_sh" id="yscs_ul" style="display: none;">
        <li>
            <i>项目编号</i>
            <input class="gsname" type="text" placeholder="请输入项目编号" id="yscs_projectno"/>
        </li>
        <li>
            <i>项目名称</i>
            <input class="gsname" type="text" placeholder="请输入项目名称" id="yscs_projectname"/>
        </li>
        <li>
            <i>区域</i>
            <select class="area_ipt" id="yscs_regionname">
                <option value="">请选择</option>
                <c:forEach items="${regional}" var="list" >
                    <option value="${list.regionid}">${list.regionname}</option>
                </c:forEach>
            </select>
        </li>
    </ul>
    <ul class="zczh_sh" id="yssl_ul" style="display: none;">
        <li>
            <i>项目编号</i>
            <input class="gsname" type="text" placeholder="请输入项目编号" id="yssl_projectno"/>
        </li>
        <li>
            <i>项目名称</i>
            <input class="gsname" type="text" placeholder="请输入项目名称" id="yssl_projectname" />
        </li>
        <li>
            <i>区域</i>
            <select class="area_ipt" id="yssl_regionname">
                <option value="">请选择</option>
                <c:forEach items="${regional}" var="list" >
                    <option value="${list.regionid}">${list.regionname}</option>
                </c:forEach>
            </select>
        </li>
    </ul>
    <ul class="zczh_sh" id="cqzj_ul" style="display: none;">
        <li>
            <i>项目编号</i>
            <input class="gsname" type="text" placeholder="请输入项目编号" id="cqzj_projectno"/>
        </li>
        <li>
            <i>项目名称</i>
            <input class="gsname" type="text" placeholder="请输入项目名称" id="cqzj_projectname"/>
        </li>
        <li>
            <i>区域</i>
            <select class="area_ipt" id="cqzj_regionname">
                <option value="">请选择</option>
                <c:forEach items="${regional}" var="list" >
                    <option value="${list.regionid}">${list.regionname}</option>
                </c:forEach>
            </select>
        </li>
    </ul>
</div>
<div class="btn_box">
    <input type="button" value="查询" class="search_btn all_btn" onclick="query();"/>
</div>
<div id="tab_box">
    <!--验收初审-->
    <div class="zczh_ch_tab pssh_box" style="display: none;">
        <table width="100%" border="0" cellspacing="0" cellpadding="0" class="table">
            <thead class="thead">
            <tr>
                <td width="35%">项目编号</td>
                <td width="44%">项目名称</td>
                <td width="21%" class="nobg">操作</td>
            </tr>
            </thead>
            <tbody id="yscs_tb">
            <%--<tr>
                <td>GC201705_0045</td>
                <td class="sec">
                    <a href="xm_detail.html">苏地2011-B-57号 地块项目</a>
                </td>
                <td class="shenbao">
                    通过
                </td>
            </tr>--%>

            </tbody>
        </table>
        <a  class="click_more" onclick="queryMore('ysch');" id="ysch_queryMore">点击查看更多信息...</a>
    </div>
    <!--验收受理-->
    <div class="zczh_ch_tab pssh_box" style="display: none;">
        <table width="100%" border="0" cellspacing="0" cellpadding="0" class="table">
            <thead class="thead">
            <tr>
                <td width="35%">项目编号</td>
                <td width="44%">项目名称</td>
                <td width="21%" class="nobg">操作</td>
            </tr>
            </thead>
            <tbody id="yssl_tb">

            </tbody>
        </table>
        <a  class="click_more" onclick="queryMore('yssl');" id="yssl_queryMore">点击查看更多信息...</a>
    </div>
    <!--抽取专家-->
    <div class="zczh_ch_tab pssh_box" style="display: none;">
        <table width="100%" border="0" cellspacing="0" cellpadding="0" class="table">
            <thead class="thead">
            <tr>
                <td width="35%">项目编号</td>
                <td width="44%">项目名称</td>
                <td width="21%" class="nobg">操作</td>
            </tr>
            </thead>
            <tbody id="cqzj_tb">
            <%--<tr>
                <td>GC201705_0045</td>
                <td class="sec">
                    <a href="xm_detail.html">苏地2011-B-57号 地块项目</a>
                </td>
                <td>
                    <a href="cqzj.html" class="shenbao">抽取专家</a>
                </td>
            </tr>--%>

            </tbody>
        </table>
        <a class="click_more" onclick="queryMore('cqzj');" id="cqzj_queryMore">点击查看更多信息...</a>
    </div>
</div>
<ul class="pssh_tab" id="pssh_tab">
    <li class="cho">验收初审</li>
    <li >验收受理</li>
    <li>抽取专家</li>
</ul>
</div>

<script type="text/javascript">
    $(document).ready(function() {
        $("#pssh_tab > li").click(function() {
            $(this).addClass("cho").siblings().removeClass("cho");
            var bb = $(this).index();
            $("#tab_box > .zczh_ch_tab").eq(bb).show().siblings().hide();//表格
            $("#tab_ul > .zczh_sh").eq(bb).show().siblings().hide();//查询条件
        });
    });
</script>
<script type="text/javascript">
var totlePage_ysch;//总页数
var pageNum_ysch;//当前页数
var total_ysch;//总数据量

var totlePage_yssl;//总页数
var pageNum_yssl;//当前页数
var total_yssl;//总数据量

var totlePage_cqzj;//总页数
var pageNum_cqzj;//当前页数
var total_cqzj;//总数据量

$(function(){
    var tab = $.cookie('tab');
if(tab=="ysch" || tab == null){
    $("#pssh_tab > li").eq(0).click();
}else if(tab=="yssl"){
    $("#pssh_tab > li").eq(1).click();
}else if(tab=="cqzj"){
    $("#pssh_tab > li").eq(2).click();
}
    loadYSCH();
    loadYSSL();
    loadCQZJ();
    clearCookie();
});
//搜索条件查询
function query(){
    //显示的查询条件标签
    var id = $(".zczh_sh:visible").attr("id");
    if(id == "yscs_ul"){
        //清空条件后查询
        $("#yscs_tb").empty();//列表
        pageNum_ysch = 1;//页数
        loadYSCH();
    }else if(id == "yssl_ul"){
        $("#yssl_tb").empty();//列表
        pageNum_yssl = 1;//页数
        loadYSSL();
    }else if(id == "cqzj_ul"){
        $("#cqzj_tb").empty();//列表
        pageNum_cqzj = 1;//页数
        loadCQZJ();
    }
}
//加载验收初审
function loadYSCH(){

    $.ajax({
        url: "yssh/getYsch",
        type: "post",
        async: false,
        dataType: "json",
        data: {
            projectno: $("#yscs_projectno").val(),
            projectname: $("#yscs_projectname").val(),
            regionid: $("#yscs_regionname").val(),
            pageNum: pageNum_ysch
        },
        success: function (resp) {
            if (resp.succ && resp.data.list.length > 0) {
                total_ysch = resp.data.page;
                pageNum_ysch = resp.data.pageNum;
                var data = resp.data.list;
                var html = "";
                for (var i = 0; i < data.length; i++) {
                    html += "<tr>" +
                            "<td>" + data[i].projectno + "</td>" +
//                            "<td> <a href='yssh/getDetail/"+data[i].projectguid+"?tab=ysch'>" + data[i].projectname + "</a></td>" +
                            "<td> <a onclick=\"showDetail('"+data[i].projectguid+"','ysch')\">" + data[i].projectname + "</a></td>" +
                            "<td class=\"shenbao\" onclick=\"ysch_approval('"+data[i].guid+"',this);\">通过</td></tr>";
                }
                $("#yscs_tb").append(html);
            } else {
                if($("#yscs_tb tr").length==0){

                    $("#yscs_tb").append("<tr><td colspan='3'>未查出数据</td></tr>");
                }
            }
            hide_queryMore("ysch");//判断是否影藏获取更多按钮
        },
        error:function(){
            alert("请求错误");
            return false;

        }
    });
}
//加载验收受理
function loadYSSL(){
    $.ajax({
        url: "yssh/getYssl",
        type: "post",
        async: false,
        dataType: "json",
        data: {
            projectno: $("#yssl_projectno").val(),
            projectname: $("#yssl_projectname").val(),
            regionid: $("#yssl_regionname").val(),
            pageNum: pageNum_yssl
        },
        success: function (resp) {
            if (resp.succ && resp.data.list.length > 0) {
                total_yssl = resp.data.page;
                pageNum_yssl = resp.data.pageNum;
                var data = resp.data.list;
                var html = "";
                for (var i = 0; i < data.length; i++) {
                    html += "<tr>" +
                            "<td>" + data[i].projectno + "</td>" +
                            //"<td> <a href='yssh/getDetail/"+data[i].projectguid+"'>" + data[i].projectname + "</a></td>" +
                            "<td> <a onclick=\"showDetail('"+data[i].projectguid+"','yssl')\">" + data[i].projectname + "</a></td>" +
                            "<td class=\"shenbao\" onclick=\"yssl_approval('"+data[i].guid+"',this);\">通过</td></tr>";
                }
                $("#yssl_tb").append(html);
            } else {
                if($("#yssl_tb tr").length==0){
                    $("#yssl_tb").append("<tr><td colspan='3'>未查出数据</td></tr>");

                }
            }
            hide_queryMore("yssl");//判断是否影藏获取更多按钮
        },
        error:function(){
            alert("请求错误");
            return false;

        }
    });
}
//加载抽取专家
function loadCQZJ(){
    $.ajax({
        url: "yssh/getCqzj",
        type: "post",
        async: false,
        dataType: "json",
        data: {
            projectno: $("#cqzj_projectno").val(),
            projectname: $("#cqzj_projectname").val(),
            regionid: $("#cqzj_regionname").val(),
            pageNum: pageNum_cqzj
        },
        success: function (resp) {
            if (resp.succ && resp.data.list.length > 0) {
                total_cqzj = resp.data.page;
                pageNum_cqzj = resp.data.pageNum;
                var data = resp.data.list;
                var html = "";
                for (var i = 0; i < data.length; i++) {
                    html += "<tr>" +
                            "<td>" + data[i].projectno + "</td>" +
                            "<td> <a onclick=\"showDetail('"+data[i].projectguid+"','cqzj')\">" + data[i].projectname + "</a></td>" +
                            "<td class=\"shenbao\" onclick=\"to_cqzj('"+data[i].guid+"','cqzj');\">抽取专家</td></tr>";
                }
                $("#cqzj_tb").append(html);
            } else {
                if($("#cqzj_tb tr").length==0){
                    $("#cqzj_tb").append("<tr><td colspan='3'>未查出数据</td></tr>");

                }
            }
            hide_queryMore("cqzj");//判断是否影藏获取更多按钮
        },
        error:function(){
            alert("请求错误");
            return false;

        }
    });
}
//加载更好按钮隐藏或者显示
function hide_queryMore(flag){
    if(flag == "ysch" ){
        if(pageNum_ysch == total_ysch ){
            $("#ysch_queryMore").hide();
        }else{
            $("#ysch_queryMore").show()
        }
    }else if(flag == "yssl"){
        if(pageNum_yssl == total_yssl ){
            $("#yssl_queryMore").hide();
        }else{
            $("#yssl_queryMore").show()
        }
    }else if(flag == "cqzj"){
        if(pageNum_cqzj == total_cqzj ){
            $("#cqzj_queryMore").hide();
        }else{
            $("#cqzj_queryMore").show()
        }
    }
}
//加载更多
function queryMore(flag) {
    if(flag == "ysch" ){
        if(pageNum_ysch < total_ysch ){
            pageNum_ysch++;
            loadYSCH();
        }
    }else if(flag == "yssl"){
        if(pageNum_yssl < total_yssl ){
            pageNum_yssl++;
            loadYSSL();
        }
    }else if(flag == "cqzj"){
        if(pageNum_cqzj < total_cqzj ){
            pageNum_cqzj++;
            loadCQZJ();
        }
    }
}
//验收初审通过
function ysch_approval(guid,obj){
    if(!confirm("确定要通过此项目吗？")){
        return false;
    }else{
        $.ajax({
            url: "yssh/yschApproval",
            type: "post",
            async: false,
            dataType: "json",
            data: {
                guid: guid
            },
            success: function (resp) {
                if (resp.succ) {
                    alert(resp.msg);
                    //query();
                    $(obj).parent().remove();
                    $("#yssl_tb").empty();//列表
                    pageNum_yssl = 1;//页数
                    loadYSSL();
                } else {
                    alert(resp.msg);
                    return false;
                }
            }
        });
    }
}
//验收受理通过
function yssl_approval(guid,obj){
    if(!confirm("确定要通过此项目吗？")){
        return false;
    }else{
        $.ajax({
            url: "yssh/ysslApproval",
            type: "post",
            async: false,
            dataType: "json",
            data: {
                guid: guid
            },
            success: function (resp) {
                if (resp.succ) {
                    alert(resp.msg);
                    $(obj).parent().remove();
                    $("#cqzj_tb").empty();//列表
                    pageNum_cqzj = 1;//页数
                    loadCQZJ();
                } else {
                    alert(resp.msg);
                    return false;
                }
            }
        });
    }
}
//显示详情
function showDetail(id,flag){
    setCookie(flag);
    window.location.href = "yssh/getDetail/"+id;
}
//存入cookie
function setCookie(flag){
    $.cookie('tab', flag);//当前标签页
    if(flag=="ysch"){
        $.cookie('pageNum', pageNum_ysch);//当前标签页
    }else if(flag=="yssl"){
        $.cookie('pageNum', pageNum_yssl);//当前标签页
    }else if(flag=="cqzj"){
        $.cookie('pageNum', pageNum_cqzj);//当前标签页
    }
}
//清除cookie
function clearCookie(){
    $.cookie('tab', null);
    $.cookie('pageNum', null);
}
function to_cqzj(id,flag){
    setCookie(flag);
    window.location.href = "yssh/gotoCqzj/"+id;
//window.location.href="<c:url value='yssh/gotoCqzj' />";
}
</script>
</body>
</html>